// 当前这个模块，api进行统一管理
import requests from "./request";
import Mockrequest from "./mock";
// 三级联动接口
// /api/product/getBaseCategoryList GET
// 返回一个promise对象
export const reqCategoryList = () =>
  requests({
    url: "/product/getBaseCategoryList",
    method: "GET",
  });

// 获取banner
export const reqGetBannerList = () => Mockrequest.get("/banner");

// 获取搜索模块数据
// /api/list
export const reqGetSearchInfo = (params) =>
  requests({
    url: "/list",
    method: "POST",
    data: params,
  });

// 获取产品详情信息
// /api/item/{skuid} GET
export const reqGoodInfo = (skuId) =>
  requests({
    url: `/item/${skuId}`,
    method: "GET",
  });

// 将产品添加到购物车中（获取更新某一个产品的个数）

export const reqAddOrUpdateShopCart = (skuId, skuNum) =>
  requests({
    url: `/cart/addToCart/${skuId}/${skuNum}`,
    method: "POST",
  });

// 获取购物车列表的接口
// /api/cart/cartList
export const reqCartList = () =>
  requests({
    url: "/cart/cartList",
    method: "GET",
  });

// 删除购物车产品接口
// /api/cart/deleteCart/{skuId}
export const reqDeleteCartById = (skuId) =>
  requests({
    url: `/cart/deleteCart/${skuId}`,
    method: "DELETE",
  });

// 修改商品的选中状态
// /api/cart/checkCart/{skuId}/{isChecked}
export const reqUpdateCheckedById = (skuId, isChecked) =>
  requests({
    url: `/cart/checkCart/${skuId}/${isChecked}`,
    method: "GET",
  });

// 获取验证码
// /api/user/passport/sendCode/{phone}
export const reqGetCode = (phone) =>
  requests({
    url: `/user/passport/sendCode/${phone}`,
    method: "GET",
  });

// 注册
// /api/user/passport/registerModule

export const reqUserRegister = (data) =>
  requests({
    url: "/user/passport/register",
    data,
    method: "POST",
  });

// 登录
// /api/user/passport/login
export const reqUserLogin = (data) =>
  requests({
    url: "/user/passport/login",
    data,
    method: "POST",
  });

// 获取用户信息[token]
// /api/user/passport/auth/getUserInfo
export const reqUserInfo = () =>
  requests({
    url: "/user/passport/auth/getUserInfo ",
    method: "GET",
  });

// 退出登录
// /api/user/passport/logout
export const reqLogOut = () =>
  requests({
    url: "/user/passport/logout",
    method: "GET",
  });

// 获取用户地址信息
// /api/user/userAddress/auth/findUserAddressList
export const reqAddressInfo = () =>
  requests({
    url: "/user/userAddress/auth/findUserAddressList ",
    method: "GET",
  });

// 获取商品清单
// /api/order/auth/trade
export const reqOrderInfo = () =>
  requests({ url: "/order/auth/trade", method: "GET" });
